package com.ymatou.apigateway.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.shenqisettlement.parameter.bean.AgentProductBean;
import com.shop2cn.iapi.sqoptrade.resp.TradingServiceResp;
import com.ymatou.apigateway.parameter.AesUtil;
import com.ymatou.apigateway.parameter.DeliverOrder;
import com.ymatou.apigateway.parameter.OpenapiReq;
import com.ymatou.apigateway.parameter.SendLogisticsResult;
import com.ymatou.apigateway.parameter.SendLogisticsReturn;
import com.ymatou.apigateway.parameter.SendlogisticsBean;
import com.ymatou.apigateway.service.OpenapiService;
import com.ymatou.apigateway.service.ShenqiSendLogisticsCall;
import com.ymatou.iapi.synctrade.service.TradingSyncService;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.business.service.shenqi.DGSQBuildProxyChainCallService;
import com.ymttest.business.service.shenqi.SqTradingCallService;
import com.ymttest.database.model.Application;
import com.ymttest.database.model.AuthCode;
import com.ymttest.database.sqlwapper.OpenApiWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

public class Ts_sqsendlogistics {

	private static OpenapiReq openapiReq;
	private static SendlogisticsBean v1sendlogisticsBean;
	private static ShenqiSendLogisticsCall shenqiSendLogisticsCall;

	private static long autotest_goodsOwnerId = Long.valueOf(EnvSetup
			.getData("autotest_goodsOwnerId"));

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("神器订单发货");
	}

	@Before
	public void caseUp() {
		openapiReq = new OpenapiReq();
		openapiReq.setMethod("sq.order.deliver");

		v1sendlogisticsBean = new SendlogisticsBean();
		shenqiSendLogisticsCall = new ShenqiSendLogisticsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(shenqiSendLogisticsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_001() {
		Logger.start(true, "订单发货");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			PayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y013");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0000", shenqiSendLogisticsCall.getCode(),
					"验证Code");

			SendLogisticsResult sendLogisticsResult = shenqiSendLogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
					.get(0);

			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) returnresult.getOrder_id(), "验证Code");
			Logger.verifyEquals(true, returnresult.isExec_success(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_002() {
		Logger.start(true, "订单发货-order_id空");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setLogistics_company_id("Y066");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(11));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0001", shenqiSendLogisticsCall.getCode(),
					"验证Code");
			Logger.verifyEquals("sendSqLogisticsInfoList[0].orderId:订单号不能小于1",
					shenqiSendLogisticsCall.getMessage(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_003() {
		Logger.start(true, "订单发货-logistics_company_name空");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(3761838699L);
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(11));
			deliverOrder.setIs_domestic_delivery(false);

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0001", shenqiSendLogisticsCall.getCode(), "验证Code");
			Logger.verifyEquals("sendSqLogisticsInfoList[0].logisticsCompanyName:may not be empty",
					shenqiSendLogisticsCall.getMessage(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_004() {
		Logger.start(true, "订单发货-tracking_number空");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(3761838699L);
			deliverOrder.setLogistics_company_id("Y066");
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0001", shenqiSendLogisticsCall.getCode(), "验证Code");
			Logger.verifyEquals(
					"sendSqLogisticsInfoList[0].trackingNumber:may not be empty",
					shenqiSendLogisticsCall.getMessage(), "验证msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_sqsendlogistics_005() {
		Logger.start(true, "订单发货-is_domestic_delivery空");
		try {
			
			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(3761838699L);
			deliverOrder.setLogistics_company_id("Y070");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(12));
			deliverOrder.setLogistics_company_name("sf");

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0000", shenqiSendLogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = shenqiSendLogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn result = results.getResults().get(0);

			Logger.verifyEquals("订单Api发货失败", result.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_006() {
		Logger.start(true, "订单发货-order_id不存在");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(1125312462);
			deliverOrder.setLogistics_company_id("Y066");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(11));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0009", shenqiSendLogisticsCall.getCode(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_007() {
		Logger.start(true, "订单发货-多笔订单发货");
		try {

			List<DeliverOrder> orders = new ArrayList<>();

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			
			for (int i = 0; i < 3; i++) {
				// 创建订单
				Logger.comment("前置数据准备");

				TradingServiceResp placeOrderResp = SqTradingCallService
						.placeOrder(productBean);

				Long userId = placeOrderResp.getUserId();
				long goodsOwnerId = placeOrderResp.getOrderList().get(0)
						.getOrderPo().getGoodsOwnerId();
				long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				BigDecimal totalPrice = placeOrderResp.getPayableAmount();

				// 支付订单
				Long thirdTradingId = SqTradingCallService.payOrder(userId,
						placeOrderResp.getTradingId());

				// 支付网关支付回调交易
				PayGateWayCallService.DGSQNotifyCall(
						String.valueOf(thirdTradingId),
						totalPrice.subtract(BigDecimal.ZERO).toString(),
						userId.intValue(), BigDecimal.ZERO.toPlainString());

				TradingSyncService.getSyncResult(orderId);
				Thread.sleep(3000);

				// 接单
				SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
				TradingSyncService.getSyncResult(orderId);

				Logger.comment("前置数据准备结束");

				DeliverOrder deliverOrder = new DeliverOrder();

				deliverOrder.setOrder_id(orderId);
				deliverOrder.setLogistics_company_id("Y066");
				deliverOrder.setTracking_number(TestDataManager
						.getRandomNum(12));
				deliverOrder.setIs_domestic_delivery(false);
				deliverOrder.setLogistics_company_name("sf");

				orders.add(deliverOrder);
			}

			OpenApiWapper openApiWapper = new OpenApiWapper();

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0000", shenqiSendLogisticsCall.getCode(), "验证Code");

			SendLogisticsResult results = shenqiSendLogisticsCall
					.getSendLogisticsResult();

			for (int i = 0; i < results.getResults().size(); i++) {
				SendLogisticsReturn result = results.getResults().get(i);

				Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders()
						.get(i).getOrder_id(), (long) result.getOrder_id(),
						"验证Code");
				Logger.verifyEquals(true, result.isExec_success(), "验证Code");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_008() {
		Logger.start(true, "订单发货一次超过10笔订单");
		try {

			List<DeliverOrder> orders = new ArrayList<>();

			for (int i = 0; i < 11; i++) {

				DeliverOrder deliverOrder = new DeliverOrder();

				deliverOrder.setOrder_id(22222222);
				deliverOrder.setLogistics_company_id("Y066");
				deliverOrder.setTracking_number(TestDataManager
						.getRandomNum(11));
				deliverOrder.setIs_domestic_delivery(false);
				deliverOrder.setLogistics_company_name("sf");

				orders.add(deliverOrder);
			}

			OpenApiWapper openApiWapper = new OpenApiWapper();

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0001", shenqiSendLogisticsCall.getCode(), "验证Code");

			Logger.verifyEquals("sendSqLogisticsInfoList:单次发货不能超过10个订单",
					shenqiSendLogisticsCall.getMessage(), "验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_009() {
		Logger.start(true, "发货业务参数Biz_content为null");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(288484)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			// openapiReq.setBiz_content("");
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0001", shenqiSendLogisticsCall.getCode(), "验证Code");

			Logger.verifyEquals("参数错误", shenqiSendLogisticsCall.getMessage(),
					"验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_010() {
		Logger.start(true, "发货业务参数Biz_content为空");
		try {

			OpenApiWapper openApiWapper = new OpenApiWapper();

			Application application = openApiWapper
					.selectApplicationBySellerId(Long.valueOf(288484)).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content("");
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0001", shenqiSendLogisticsCall.getCode(), "验证Code");

			Logger.verifyEquals("参数错误", shenqiSendLogisticsCall.getMessage(),
					"验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_011() {
		Logger.start(true, "非货头发货");
		try {

			long orderId = 1420039407;

			long sellerId = 500811132;

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y013");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(sellerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0000", shenqiSendLogisticsCall.getCode(),
					"验证Code");

			SendLogisticsResult sendLogisticsResult = shenqiSendLogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
					.get(0);

			Logger.verifyEquals("找不到订单信息", returnresult.getMsg(), "msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_012() {
		Logger.start(true, "订单多次部分发货");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			PayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");
			
			for (int i = 0; i < 2; i++) {
				
				OpenApiWapper openApiWapper = new OpenApiWapper();

				DeliverOrder deliverOrder = new DeliverOrder();

				deliverOrder.setOrder_id(orderId);
				deliverOrder.setLogistics_company_id("Y013");
				deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
				deliverOrder.setIs_domestic_delivery(false);
				deliverOrder.setLogistics_company_name("sf");
				deliverOrder.setPartial_delivery_status(1);

				List<DeliverOrder> orders = new ArrayList<>();
				orders.add(deliverOrder);

				v1sendlogisticsBean.setDeliver_orders(orders);

				Application application = openApiWapper
						.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

				String app_id = application.getApp_id();
				String app_secret = application.getApp_secret();

				AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
						.get(0);

				openapiReq.setApp_id(app_id);
				openapiReq.setSign_method("MD5");
				openapiReq.setAuth_code(authCode.getAuth_code());
				openapiReq.setTimestamp(YMTDateUtil.getSysTime());
				openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
				openapiReq.setBiz_content(new FormatUtil()
						.beanToGSONString(v1sendlogisticsBean));
				openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
						AesUtil.decrypt(app_secret)));

				String url = String
						.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
								app_id);
				shenqiSendLogisticsCall.setUrl(url);

				shenqiSendLogisticsCall.setData(openapiReq);
				shenqiSendLogisticsCall.callService();

				Logger.verifyEquals("0000", shenqiSendLogisticsCall.getCode(),
						"验证Code");

				SendLogisticsResult sendLogisticsResult = shenqiSendLogisticsCall
						.getSendLogisticsResult();
				SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
						.get(0);

				Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
						.getOrder_id(), (long) returnresult.getOrder_id(), "验证Code");
				Logger.verifyEquals(true, returnresult.isExec_success(), "验证Code");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_013() {
		Logger.start(true, "订单一次部分发货，一次完整发货");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			PayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");
			
			for (int i = 0; i < 2; i++) {
				
				OpenApiWapper openApiWapper = new OpenApiWapper();

				DeliverOrder deliverOrder = new DeliverOrder();

				deliverOrder.setOrder_id(orderId);
				deliverOrder.setLogistics_company_id("Y013");
				deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
				deliverOrder.setIs_domestic_delivery(false);
				deliverOrder.setLogistics_company_name("sf");
				deliverOrder.setPartial_delivery_status(i + 1);

				List<DeliverOrder> orders = new ArrayList<>();
				orders.add(deliverOrder);

				v1sendlogisticsBean.setDeliver_orders(orders);

				Application application = openApiWapper
						.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

				String app_id = application.getApp_id();
				String app_secret = application.getApp_secret();

				AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
						.get(0);

				openapiReq.setApp_id(app_id);
				openapiReq.setSign_method("MD5");
				openapiReq.setAuth_code(authCode.getAuth_code());
				openapiReq.setTimestamp(YMTDateUtil.getSysTime());
				openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
				openapiReq.setBiz_content(new FormatUtil()
						.beanToGSONString(v1sendlogisticsBean));
				openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
						AesUtil.decrypt(app_secret)));

				String url = String
						.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
								app_id);
				shenqiSendLogisticsCall.setUrl(url);

				shenqiSendLogisticsCall.setData(openapiReq);
				shenqiSendLogisticsCall.callService();

				Logger.verifyEquals("0000", shenqiSendLogisticsCall.getCode(),
						"验证Code");

				SendLogisticsResult sendLogisticsResult = shenqiSendLogisticsCall
						.getSendLogisticsResult();
				SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
						.get(0);

				Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
						.getOrder_id(), (long) returnresult.getOrder_id(), "验证Code");
				Logger.verifyEquals(true, returnresult.isExec_success(), "验证Code");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_014() {
		Logger.start(true, "订单发货，发货时间早于下单时间，发货失败");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			PayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y013");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");
			deliverOrder.setDelivery_time(YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDHMSS));

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0009", shenqiSendLogisticsCall.getCode(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_015() {
		Logger.start(true, "订单发货，订单未接单，传入发货时间，发货失败");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
//			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
//					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			PayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			Logger.comment("前置数据准备结束");

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y013");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");
			deliverOrder.setDelivery_time(YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDHMSS));

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0009", shenqiSendLogisticsCall.getCode(),
					"验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_016() {
		Logger.start(true, "订单发货，传入发货时间，发货成功");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			PayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y013");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");
			deliverOrder.setDelivery_time(YMTDateUtil.getBeforeOrNextHour(1, YMTDateUtil.YMDHMSS));

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0000", shenqiSendLogisticsCall.getCode(),
					"验证Code");

			SendLogisticsResult sendLogisticsResult = shenqiSendLogisticsCall
					.getSendLogisticsResult();
			SendLogisticsReturn returnresult = sendLogisticsResult.getResults()
					.get(0);

			Logger.verifyEquals(v1sendlogisticsBean.getDeliver_orders().get(0)
					.getOrder_id(), (long) returnresult.getOrder_id(), "验证Code");
			Logger.verifyEquals(true, returnresult.isExec_success(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@SuppressWarnings("static-access")
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_sqsendlogistics_017() {
		Logger.start(true, "订单发货，发货时间早于接单时间，发货失败");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			Long userId = placeOrderResp.getUserId();
			long goodsOwnerId = placeOrderResp.getOrderList().get(0)
					.getOrderPo().getGoodsOwnerId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			PayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(goodsOwnerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			OpenApiWapper openApiWapper = new OpenApiWapper();

			DeliverOrder deliverOrder = new DeliverOrder();

			deliverOrder.setOrder_id(orderId);
			deliverOrder.setLogistics_company_id("Y013");
			deliverOrder.setTracking_number(TestDataManager.getRandomNum(13));
			deliverOrder.setIs_domestic_delivery(false);
			deliverOrder.setLogistics_company_name("sf");
			deliverOrder.setDelivery_time(YMTDateUtil.getBeforeOrNextSecond(-3, YMTDateUtil.YMDHMSS));

			List<DeliverOrder> orders = new ArrayList<>();
			orders.add(deliverOrder);

			v1sendlogisticsBean.setDeliver_orders(orders);

			Application application = openApiWapper
					.selectApplicationBySellerId(autotest_goodsOwnerId).get(0);

			String app_id = application.getApp_id();
			String app_secret = application.getApp_secret();

			AuthCode authCode = openApiWapper.selectAuthCodeByAppId(app_id)
					.get(0);

			openapiReq.setApp_id(app_id);
			openapiReq.setSign_method("MD5");
			openapiReq.setAuth_code(authCode.getAuth_code());
			openapiReq.setTimestamp(YMTDateUtil.getSysTime());
			openapiReq.setNonce_str(TestDataManager.getRandomNum(31));
			openapiReq.setBiz_content(new FormatUtil()
					.beanToGSONString(v1sendlogisticsBean));
			openapiReq.setSign(OpenapiService.generateMD5(openapiReq,
					AesUtil.decrypt(app_secret)));

			String url = String
					.format("http://apigateway.ymatou.com/apigateway/v1?app_id=%s&method=sq.order.deliver",
							app_id);
			shenqiSendLogisticsCall.setUrl(url);

			shenqiSendLogisticsCall.setData(openapiReq);
			shenqiSendLogisticsCall.callService();

			Logger.verifyEquals("0009", shenqiSendLogisticsCall.getCode(), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
